RHIDP-14000: add integration tests for /v1/responses endpoint#1933
Conversation
Co-authored-by: Cursor <cursoragent@cursor.com>
|
Warning Review limit reached
More reviews will be available in 6 minutes and 41 seconds. Learn how PR review limits work. Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file). ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (1)
WalkthroughAdds a new integration test module ChangesIntegration tests for /v1/responses endpoint
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
✨ Simplify code
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@tests/integration/endpoints/test_responses_integration.py`:
- Around line 351-354: The current assertions on lines 351-354 only verify that
individual substrings are present in body_str but do not enforce the order in
which the SSE events appear. Replace the individual substring assertions with a
test that explicitly validates the event sequence order. Verify that "event:
response.created" appears before "event: response.completed", which in turn
appears before "data: [DONE]", and that "Content blocked by safety shield"
appears in the appropriate position within this sequence. This ensures the
streaming contract properly validates that events arrive in the expected order,
not just that they exist somewhere in the response.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: 2da72afa-7c1a-43af-b69d-c7ad718e1cc7
📒 Files selected for processing (1)
tests/integration/endpoints/test_responses_integration.py
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (12)
- GitHub Check: Pylinter
- GitHub Check: build-pr
- GitHub Check: unit_tests (3.12)
- GitHub Check: unit_tests (3.13)
- GitHub Check: E2E: library mode / ci / group 1
- GitHub Check: E2E: library mode / ci / group 2
- GitHub Check: E2E: library mode / ci / group 3
- GitHub Check: E2E: server mode / ci / group 3
- GitHub Check: E2E: server mode / ci / group 2
- GitHub Check: E2E Tests for Lightspeed Evaluation job
- GitHub Check: Konflux kflux-prd-rh02 / lightspeed-stack-on-pull-request
- GitHub Check: Konflux kflux-prd-rh02 / lightspeed-stack-0-6-on-pull-request
🧰 Additional context used
📓 Path-based instructions (1)
tests/**/*.py
📄 CodeRabbit inference engine (AGENTS.md)
tests/**/*.py: Use pytest for all unit and integration tests; do not use unittest
Usepytest.mark.asynciomarker for async tests
Files:
tests/integration/endpoints/test_responses_integration.py
Signed-off-by: Jordan Dubrick <jdubrick@redhat.com>
Description
Added 4 integration tests for the /v1/responses endpoint that exercise the handler → DB persistence path with real configuration and an in-memory SQLite database (Llama Stack client remains mocked)
Non-streaming success: verifies UserConversation and UserTurn rows are correctly created with proper user ID, model, provider, message count, and response ID
Shield-blocked moderation: verifies the modr_ prefix branching logic sets last_response_id = None on the conversation while still recording the moderation turn for auditing, and confirms the LLM is never invoked
store=False: verifies zero DB records are written when persistence is explicitly disabled
Streaming shield-blocked: verifies SSE event format (response.created, response.completed, [DONE]) and that post-stream DB persistence correctly writes the moderation turn after the stream is fully consumed
Type of change
Tools used to create PR
Identify any AI code assistants used in this PR (for transparency and review context)
Related Tickets & Documents
Checklist before requesting a review
Testing
Summary by CodeRabbit
Release Notes